package com.tfswue.mxj.service;

import com.tfswue.mxj.apis.UserClinet;
import com.tfswue.mxj.entity.Order;
import com.tfswue.mxj.entity.User;
import com.tfswue.mxj.mapper.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class OrderService {
    @Autowired
    private OrderMapper orderMapper;
    @Autowired
    private RestTemplate restTemplate;
    @Autowired
    private UserClinet userClinet;
    public Order getOrderById(Long id){
        Order order = orderMapper.selectById(id);
        User user = userClinet.getUserById(order.getUserId());
        order.setUser(user);
//        order.setUser(restTemplate.getForObject
//                ("http://user-server/api/users/"+order.getUserId(), User.class));
        return order;
    }
}